<?
include_once("./_common.php");

auth_check($auth[$sub_menu], "w");

if ($is_admin != "super" && $w == "") alert("최고관리자만 접근 가능합니다.");

$html_title = "쿠폰관리";
if ($w == "") 
{
    $gr_id_attr = "required";
    $gr[gr_use_access] = 0;
    $html_title .= " 생성";
} 
else if ($w == "u") 
{
    $gr_id_attr = "readonly style='background-color:#dddddd'";
    $cu = sql_fetch(" select * from coupon_record where cu_no = '$cu_no' ");
    $html_title .= " 수정";
} 
else
    alert("제대로 된 값이 넘어오지 않았습니다.");

$g4[title] = $html_title;
include_once("./admin.head.php");
$rand_num=rand("0000","9999");

$upload_max_filesize = number_format($board[bo_upload_size]) . " 바이트";

?>

<table width=100% cellpadding=0 cellspacing=0>
<form name=fcoupon method=post action="./coupon_form_update.php" autocomplete="off" enctype=multipart/form-data>
<input type=hidden name=w    value='<?=$w?>'>
<input type=hidden name=sfl  value='<?=$sfl?>'>
<input type=hidden name=stx  value='<?=$stx?>'>
<input type=hidden name=sst  value='<?=$sst?>'>
<input type=hidden name=sod  value='<?=$sod?>'>
<input type=hidden name=page value='<?=$page?>'>
<input type=hidden name=cu_no value='<?=$cu[cu_no]?>'>
<colgroup width=20% class='col1 pad1 bold right'>
<colgroup width=30% class='col2 pad2'>
<colgroup width=20% class='col1 pad1 bold right'>
<colgroup width=30% class='col2 pad2'>
<tr class='ht'>
    <td colspan=4 class=title align=left><img src='<?=$g4[admin_path]?>/img/icon_title.gif'> <?=$html_title?></td>
</tr>
<tr><td colspan=4 class='line1'></td></tr>
<script language=Javascript>
	function createNumber() {
	var num_1=parseInt(Math.random()*("<?=$rand_num?>"));
	var num_2=parseInt(Math.random()*("<?=$rand_num?>"));
	var num_3=parseInt(Math.random()*("<?=$rand_num?>"));
	var num_4=parseInt(Math.random()*("<?=$rand_num?>"));
	document.getElementById("cu_number").value=num_1+"-"+num_2+"-"+num_3+"-"+num_4;
}
</script>
<tr class='ht'>
    <td>쿠폰번호</td>
    <td colspan=3><input type='text' class=ed name=cu_number id="cu_number" size=31 maxlength=30 <?=$gr_id_attr?> itemname='쿠폰번호' value='<?=$cu[cu_number]?>'>&nbsp;<? if($w=="") { ?><input type=button value="쿠폰번호 생성" style="height:20px;border:1px #cccccc solid;font-size:8pt" onclick="createNumber();" class=ed><? } ?></td>
</tr>
<tr class='ht'>
    <td>쿠폰내용</td>
    <td colspan=3>
        <input type='text' class=ed name=cu_content size=40 required itemname='쿠폰내용' value='<?=get_text($cu[cu_content])?>'>
    </td>
</tr>
<tr class='ht'>
    <td>쿠폰갯수</td>
    <td colspan=3><? echo "<input type=text size=30 name='cu_limit' value='$cu[cu_limit]' size=40>"; ?></td>
</tr>
<!-- 
<tr class='ht'>
    <td>적립포인트</td>
    <td colspan=3><? echo "<input type=text size=30 name='cu_point' value='$cu[cu_point]' size=40>"; ?></td>
</tr>
-->
<tr class='ht'>
	<td>이미지 파일</td>
	<td colspan=3>
	<?
	if ($cu[cu_img]) {
		$temp_name = explode('||',$cu[cu_img]); 
		$original_file_name = $temp_name[1];

		echo "첨부된 파일 : $original_file_name</font><BR>";
	}
	?>
					
	<input type='file' class='ed' name='upfile' title='파일 용량 <?=$upload_max_filesize?> 이하만 업로드 가능'></td>

<tr>
<tr><td colspan=4 class='line2'></td></tr>
</table>

<p align=center>
    <input type=submit class=btn1 accesskey='s' value='  확  인   '>&nbsp;
    <input type=button class=btn1 value='  목  록   ' onclick="document.location.href='./coupon_list.php?bo_table=coupon<?=$qstr?>';">
</form>

<script language='JavaScript'>
if (document.fcoupon.w.value == '')
    document.fcoupon.cu_content.focus();
else
    document.fcoupon.cu_content.focus();

if(document.getElementById("cu_number").value=='')
	createNumber();

</script>

<?
include_once ("../admin.tail.php");
?>
